﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CrusadeGmTool.Net
{
    public enum AcctSearchType : byte
    {
        Username = 0,
        IP = 1,
    }

    /// <summary>
    /// Packet used to login as a Remote admin
    /// </summary>
    /// 

    public class ActivateRemoteAdminPacket : Packet
    {
        public ActivateRemoteAdminPacket()
            : base()
        {
            
            byte[] keys = new byte[4] { 0x01, 0x02, 0x03, 0x04 };
            Stream.Write(keys, 0, 4);
        }
    }

    public class RemoteAdminLoginPacket : Packet
    {
        public RemoteAdminLoginPacket(string username, string password)
            : base(0xF1, "Remote Admin Login", 61)
        {
            if (username.Length > 30)
            {
                throw new ArgumentException("username must be less than or equal to 30 characters");
            }

            if (password.Length > 30)
            {
                throw new ArgumentException("password must be less than or equal to 30 characters");
            }
            Stream.Write((byte)0x02);
            Stream.WriteAsciiFixed(username, 30);
            Stream.WriteAsciiFixed(password, 30);
        }
    }
    /// <summary>
    /// Request info from the server (number of player, etc)
    /// </summary>
    public class ServerInfoRequestPacket : Packet
    {
        public ServerInfoRequestPacket()
            : base(0xF1, "Server Info Reqest", 4)
        {
            Stream.Write((byte)0x04);
        }
    }
    /// <summary>
    /// used to search for an account, by name or IP
    /// </summary>
    public class AccountSearchPacket : Packet
    {
        public AccountSearchPacket(AcctSearchType searchType, string term)
            : base(0xF1, "Account Search")
        {
            EnsureCapacity(1 + 2 + 2 + term.Length + 1);

            Stream.Write((byte)0x05);
            Stream.Write((byte)searchType);
            Stream.WriteAsciiNull(term);
        }
    }


}
